﻿using LeRenard.Core.Ui.ConsoleUtils;
using System;

namespace LeRenard.Core.ConsoleUtils.Example
{
    class Program
    {
        static void Main(string[] args)
        {
            try {
                Console.WriteLine("====== [TEST CONSOLESESSION CLASS] ======");
                ConsoleSession.WriteLine(1);
                
                ConsoleSession.Indent();
                Console.WriteLine("{0}1) Perform divide by zero", ConsoleSession.GetIndentationString(' '));
                DivideByZero();
                ConsoleSession.UnIndent();
            } catch (Exception ex) {
                var theException = new OutOfMemoryException("Divide by zero uses memory.", ex);

                ConsoleSession.WriteException(theException, true);
            } finally {
                ConsoleSession.UnIndent();
            }

            ConsoleSession.WriteLine(1);
            Console.WriteLine("========= [PRESS ENTER TO EXIT] =========");
            Console.ReadLine();
        }

        private static void DivideByZero()
        {
            var x = 0;
            var y = 0;

            var impossible = x / y;
        }
    }
}
